<?php

namespace app\common\model\mall\goods;

use think\Model;

class Salespec extends Model
{
    // 表名
    protected $name = 'mall_goods_salespec';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'goods_id_text',

    ];

    public function getGoodsIdTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['goods_id']) ? $data['goods_id'] : '');
        $names = db("mall_goods_goods")->where("id",$value)->column("productno");
        return $names ? $names : '';
    }


    public function goods()
    {
        return $this->belongsTo('Goods', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
